package com.peter.ai.util;

import java.io.File;

import com.peter.ai.voice.BaiduClientIntance;

public class MyThread extends Thread {

	private int index;
	private File[] files;
	private BaiduClientIntance instance;
	private String mp3Dir;

	public MyThread(int index, File[] files, BaiduClientIntance instance, String mp3Dir) {
		this.index = index;
		this.files = files;
		this.mp3Dir = mp3Dir;
		this.instance = instance;
	}

	@Override
	public void run() {
		for (File file : files) {
			int i = Integer.parseInt(file.getName().substring(0, 2));
			if (file.getName().contains(".txt") && i >= index * 20 && i < (index + 1) * 20) {
				String text = FileUtils.readFile(file.getAbsolutePath());
				instance.text2Voice(file.getName().substring(0, file.getName().indexOf(".")), text, mp3Dir);
			}
		}
	}
}
